<html>
<head>
    <title>修改</title>
</head>
<link rel="stylesheet" href="/static/layui/css/layui.css" />
<body>

<form class="layui-form"  action="" lay-filter="edit">
    <input type="hidden" name="l_id">
    <div class="layui-form-item">
        <label class="layui-form-label">租户姓名：</label>
        <div class="layui-input-inline">
            <input type="text" name="l_name" id="l_name" lay-verify="required" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">租户电话：</label>
        <div class="layui-input-inline">
            <input type="text" name="l_tel" id="l_tel" lay-verify="required" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">性别：</label>
        <div class="layui-input-block">
            <input type="radio" name="l_sex" value="男" title="男" checked="">
            <input type="radio" name="l_sex" value="女" title="女">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">身份证号：</label>
        <div class="layui-input-inline">
            <input type="text" name="l_idcard" id="l_idcard" lay-verify="required" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">籍贯：</label>
        <div class="layui-input-inline">
            <input type="text" name="l_nativeplace" id="l_nativeplace" lay-verify="required" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">添加时间：</label>
        <div class="layui-input-inline">
            <input type="text" name="l_addtime" id="l_addtime" lay-verify="required" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
        </div>
    </div>
</form>
</body>

<script src="/static/js/system.js"></script>
<script src="/static/js/jquery-3.3.1.js"></script>
<script src="/static/layui/layui.js"></script>
<script>
    //Demo
    layui.use(['form','laydate'], function(){
        var form = layui.form,laydate = layui.laydate;
        laydate.render({
            elem: '#l_addtime'
        });
        $.ajax({
            url:'/LesseeServlet?action=findById',
            type:"get",
            dataType:"json",
            data:{"l_id":getQueryString("l_id")},
            success:function (da) {
                console.log(da);
                if (da.code == 200) {
                    //form.val("edit",da.data);
                    form.val("edit", { //formTest 即 class="layui-form" 所在元素属性 lay-filter="" 对应的值
                        /*"h_estate": da.date.h_estate+da.date.h_unitNumber+da.date.h_roomNo // "name": "value"
                        ,"l_name": da.date.l_name,*/
                        "l_id": da.date.l_id
                        ,"l_name": da.date.l_name
                        ,"l_tel": da.date.l_tel
                        ,"l_sex": da.date.l_sex
                        ,"l_idcard": da.date.l_idcard
                        ,"l_nativeplace": da.date.l_nativeplace
                        ,"l_addtime": layui.util.toDateString(da.date.l_addtime, 'yyyy-MM-dd')
                    });
                } else {
                    layer.msg("查询数据失败！");
                }
            }
        });
        //监听提交 15039939677
        form.on('submit(formDemo)', function(data){
            var data1 = form.val("edit");
            console.log(data1);
            $.ajax({
                url:'/LesseeServlet?action=update',
                type:"post",
                dataType:"json",
                data:data1,
                success:function (da) {
                    if (da.code == 200) {
                        layer.alert("修改成功！", function () {
                            parent.layer.closeAll();
                        });
                    } else {
                        layer.msg("修改失败！");
                    }
                }
            });
            return false;
        });
    });
</script>
</html>
